<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .content {
            width: 400px;
            height: 400px;
            border: 1px solid red;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-wrap: wrap;
        }

        .inner {
            width: 100px;
            height: 100px;
            border: 1px solid green;
            margin: 10px;
            text-align: center;
            line-height: 100px;
        }
    </style>
</head>

<body>
    <div class="content">
        <div class="inner">1</div>
        <div class="inner">2</div>
        <div class="inner">3</div>
        <div class="inner">4</div>
        <div class="inner">5</div>
        <div class="inner">6</div>
        <div class="inner">7</div>
        <div class="inner">8</div>
        <div class="inner">9</div>
    </div>
    <script>
        //获取点击的DIV内容，并进行控制台输出，且被点击的DIV背景颜色为pink，其他div为默认颜色
        document.querySelector('.content').onclick = function (event) {
            console.log(event.target);
            if (event.target.className == 'content' || event.target == this) {
                return;
            }
            for (var div of this.children) {
                div.style.backgroundColor = '#ffffff';
            }
            console.log(event.target.innerText);
            event.target.style.backgroundColor = 'pink';
        }
    </script>
</body>

</html>